﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnumerateListEx
{
    class Program
    {
        
        static void Main(string[] args)
        {
            TodoRepository todoCrud = new TodoRepository();

            string input;
            do
            {
                Console.WriteLine("Enter a command");


                input = Console.ReadLine();

                switch(input)
                {
                    case "add":
                        Console.WriteLine("Enter the text for your Todo Item and press enter");
                        string todoText = Console.ReadLine();
                        int id = todoCrud.AddTodoItem(todoText);
                        Console.WriteLine("Todo Item added with ID {0}", id);
                        break;
                    case "delete":
                        Console.WriteLine("Enter the ID for the Todo Item you wish to delete");
                        string todoId = Console.ReadLine();
                        todoCrud.DeleteTodoItem(int.Parse(todoId));
                        Console.WriteLine("Todo Item deleted");
                        break;
                    case "display":
                        Console.WriteLine("Here are your current Todo Items");
                        List<Todo> todoItems = todoCrud.GetTodoItems();
                        foreach (Todo todo in todoItems)
                        {
                            Console.WriteLine("ID {0}.  Your text: '{1}'.  Timestamp: {2}", todo.Id, todo.TodoText, todo.Timestamp.ToShortDateString());
                        }
                        break;
                    default:
                        Console.WriteLine("Invalid command please try again");
                        break;
                }
            } while (input != "exit");
        }
    }
}
